#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

void* MyThreadStrat(void* arg)
{
    // 两种退出方法，退出则不会打印下方内容
    pthread_exit(NULL);
    pthread_cancel(pthread_self());

    printf("MyThreadStrat :%s\n", (char*)arg);

    return NULL;
}

int main()
{



    pthread_t tid;
    for(int i = 0; i < 2; i++)
    {
        int ret = pthread_create(&tid, NULL, MyThreadStrat, NULL);
        //start 是JAVA加入的概念
        //tid.start();
        if(ret != 0)
        {
            perror("pthread_create");
            return 0;
        }
    }

    while(1)
    {
        printf("i am main thread\n");
        sleep(1);
    }
    return 0;
}